package com.exam.kotlindemo.factory

import com.exam.kotlindemo.reflect.Product


/**
 * ProductFactory
 *
 *
 * Created by Alex Y. Lan on 2021/3/1.
 * Copyright © 2021 Alex Y. Lan All rights reserved.
 *
 *
 */
class ProductFactory {
    fun getInstance(ClassName: String?): Product? {
        var concreteProduct: Product? = null
        try {
            val productCls = Class.forName(ClassName!!)
            concreteProduct = productCls.newInstance() as Product
        } catch (e: Exception) {
            e.printStackTrace()
        }
        return concreteProduct
    }
}